﻿@model PresentationMVC.Models.JobBookingModel

<div id="DivGrid">
    <div class="success-msg">
        @ViewData["DELETE_MSG"]</div>
    @{
    
        var grid = new WebGrid(Model.AllJobBooking,
                                               defaultSort: "First Name",
                                               rowsPerPage: 7, fieldNamePrefix: "",
                                               canPage: true, canSort: true,
                                               pageFieldName: "Page", sortFieldName: "srt"
                                               );
    }
    <table cellpadding="0" cellspacing="0" width="100%">
        <tr>
            <td>
                @grid.Table(tableStyle: "listing-border", headerStyle: "gridhead", footerStyle: "paging", rowStyle: "td-dark", alternatingRowStyle: "td-light",
                                columns:
                                    grid.Columns(
                                        grid.Column("Customer.FirstName", "Customer Name", style: "colTitle"),
                                        grid.Column("Staff.FirstName", "Staff Name", style: "colTitle"),
                                        grid.Column("BookingType.Type", "Booking Type", style: "colTitle"),
                                        grid.Column("Status.Type", "Status", style: "colTitle"),
                                        grid.Column("FromCity", "From City", style: "colTitle"),
                                        grid.Column("FromPostcode", "From Postcode", style: "colTitle"),
                                        grid.Column("ToCity", "To City", style: "colTitle"),
                                        grid.Column("ToPostcode", "To Postcode", style: "colTitle"),
                                        grid.Column("WaitingCharge", "WaitingCharge", style: "colTitle"),
                                        grid.Column("Fare", "Fare", style: "colTitle"),
                                        grid.Column("Refund.RefundAmount", "Refund", style: "colTitle"),
                                        grid.Column("Note", "Note", style: "colTitle"),
                                        grid.Column("JobDateTime", "JobDateTime", style: "colTitle"),
                                        grid.Column(header: "Edit", format: @<text><a href="@Url.Action("Edit", "Job", new { id = item.id })" >Edit</a></text>, style: "colOperation"),
                                        grid.Column(header: "Delete", format: @<text>@Ajax.ActionLink("Delete", "Delete", new { id = item.id, Page = grid.PageIndex + 1 }, new AjaxOptions
                                                    {
                                                        UpdateTargetId = "DivGrid",
                                                        InsertionMode = InsertionMode.Replace,
                                                        OnBegin = "return ConfirmDelete();",
                                                        LoadingElementId = "resultLoadingDiv"
                                                    })</text>, style: "colOperation")
                                  ))
            </td>
        </tr>
    </table>
    @*@LocalHelpers.DoPager(Html, "Index", grid, 10, new { CurrentFilter = ViewBag.CurrentFilter })*@
    @LocalHelpers.DoAjaxPager(Ajax, new AjaxOptions
                                                    {
                                                        UpdateTargetId = "DivGrid",
                                                        InsertionMode = InsertionMode.Replace,
                                                        LoadingElementId = "resultLoadingDiv"
                                                    }, Html, "ReloadGrid", grid, 10, new { CurrentFilter = ViewBag.CurrentFilter })
    <script type="text/javascript">
        function ConfirmDelete() {
            return confirm("Are you sure you want to delete contacts?");
        }
    </script>
</div>
